import 'package:flutter/material.dart';
import 'package:bookapp/containers/entrance.dart';
import 'package:bookapp/routers/application.dart';
import 'package:fluro/fluro.dart';
import 'package:bookapp/helpers/constants.dart';


class Login extends StatefulWidget {
  const Login({Key? key}) : super(key: key);

  @override
  State<Login> createState() => _LoginState();
}

class _LoginState extends State<Login> {
  final TextEditingController _emailFilter = TextEditingController();
  final TextEditingController _passwordFilter = TextEditingController();

  @override
  void initState(){
    super.initState();
  }



  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        margin: EdgeInsets.symmetric(horizontal:Constants.pageMargin),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              '登录',
              style: TextStyle(
                color:Color(AppColors.fontColor),
                fontSize: 24.0,
              ),
            ),
            Container(
              margin: EdgeInsets.only(bottom:20.0,top:60.0),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(4.0),
                child: TextField(
                  cursorColor: Colors.white,
                  controller: _emailFilter,
                  decoration: InputDecoration(
                    hintText: '（邮箱）直接点击登录进入主页面',
                    border: InputBorder.none,
                    fillColor: Color(AppColors.themeColorGray),
                    filled: true,
                    hintStyle: TextStyle(
                      color: Colors.grey,
                      fontSize:16.0,
                    ),
                  ),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(bottom:20.0),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(4.0),
                child: TextField(
                  onChanged: (value){print(value);},
                  controller: _passwordFilter,
                  obscureText: true,
                  decoration: InputDecoration(
                    hintText: '（密码）暂时没有接入API',
                    border: InputBorder.none,
                    fillColor: Color(AppColors.themeColorGray),
                    filled: true,
                    hintStyle: TextStyle(
                      color: Colors.grey,
                      fontSize:16.0,
                    ),
                  ),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(bottom:40.0),
              height: 48.0,
              decoration: BoxDecoration(
                color: Color(AppColors.mainColor),
                borderRadius: BorderRadius.circular(4.0),
              ),
              child: Material(
                color: Colors.transparent,
                child: InkWell(
                  onTap: (){
                    Navigator.of(context).pushAndRemoveUntil(new MaterialPageRoute(builder: (context) => Entrance()),
                            (route) => route == null);
                  },
                  child: Center(
                    child: Text(
                      '登录',
                      style: TextStyle(
                        color: Colors.white,
                        fontFamily: 'Poppins-Bold',
                        fontSize: 18,
                        letterSpacing: 1.0,
                      ),
                    ),
                  ),
                ),
              ),
            ),

            InkWell(
              onTap: ()=> {},
              child: Text(
                '',
                style: TextStyle(
                  color: Color(AppColors.mainColor),
                  fontFamily: "Poppins-Bold",
                ),
              ),
            ),

            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  '还没有账号? ',
                  style: TextStyle(
                    fontFamily: "Poppins-Medium",
                    color: Color(AppColors.fontColorGray),
                  ),
                ),
                InkWell(
                  onTap: (){
                    Application.getRouter().navigateTo(
                      context,
                      '/register',
                      transition: TransitionType.native,
                    );
                  },
                  child: Text(
                    '立即注册',
                    style: TextStyle(
                      color: Color(AppColors.mainColor),
                      fontFamily: "Poppins-Bold",
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
